package com.job.service;

import com.job.dao.ResumeDao;
import com.job.model.Resume;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 个人简历
 * @author hasee
 */
@Service
public class ResumeService {
    private ResumeDao resumeDao;


    public void setResumeDao(ResumeDao resumeDao) {
        this.resumeDao = resumeDao;
    }

    /**
     * 获取第一份简历
     * @param userId
     * @return
     */
    @Transactional
    public Resume getFirstResume(int userId) {
       List<Resume> resumeList= resumeDao.getResume(userId);
     if (resumeList==null||resumeList.isEmpty()){
       return null;

     }else {
      Resume resume=resumeList.get(0);
      resumeList.clear();
      return resume;
     }
    }

    /**
     * 获取第二份简历
     * @param userId
     * @return
     */
    @Transactional
    public Resume getSenconResum(int userId){
      try {
          return resumeDao.getResume(userId).remove(1);
      }catch (Exception e){
          e.printStackTrace();
          System.out.println("拿不到第二份简历");
          return null;
      }
    }
}
